$(function () {



    //顶部右侧表示鼠标移入事件
    $(".header1-1-2 p").on("mouseenter", function () {
        $(this).css("color", "red")
    }).on("mouseleave", function () {
        $(this).css("color", "")
    })

    //点击注册事件
    $(".header1-zc").on("click", function () {
        // window.location = "reg.html"
        window.open("reg.html","_blank")
    })

    //点击登陆事件
    $(".header1-dl").on("click", function () {
        // window.location = "login.html"
        window.open("login.html","_blank")
    })

    //判断是否有人登陆
    if (JSON.parse(localStorage.getItem("users")) != null) {
        var uname = JSON.parse(localStorage.getItem("users")).u_name

        $(".header1-xx").show()
        $("#header1-cc").hide()
        $("#header1-dd").hide()


        $(".deader1-id").text(uname).css("color", "red")
        $(".deader1-tc").css("color", "#a00000")
        $(".deader1-tc").on("click", function () {

        })


    } else {
        $(".header1-xx").hide()
        $("#header1-cc").show()
        $("#header1-dd").show()
    }

    $(".deader1-tc").on("click", function () {
        
        layer.alert("你个憨憨要退出吗?", {
            icon: 1,
            time: 10000,                          //5秒后关闭
            btn: ["是", "你才是憨憨"]                   //几个按钮和内容
        }, (index) => {
            layer.close(index);
            localStorage.clear()
            window.location.reload()
        }, () => { })

    })

    $(".header1-gwc").on("click",function(){
        // window.location.assign("addcart.html")
        window.open("addcart.html","_blank")
    })


    $(".header2-1").on("click",function(){
        window.open("index.html","_blank")
    })




})